#version 330

layout (location = 0) in vec3 iVertex;
layout (location = 1) in vec3 iNormal;
layout (location = 2) in vec2 iTexUV;

uniform mat4 M4_CAMERA_FROM_WORLD;
uniform mat4 M4_CLIP_FROM_CAMERA;
uniform vec2 V2_CAM_CLIP;

//out vec3 ioPos;
out vec3 ioNormal;
out vec2 ioTexUV;
out float ioDepth;

void main()
{
	vec4 Pos = M4_CAMERA_FROM_WORLD * vec4(iVertex, 1.0);
	//ioPos = Pos.xyz;
	gl_Position = M4_CLIP_FROM_CAMERA * Pos;
	
	ioNormal = normalize(vec3(M4_CAMERA_FROM_WORLD * vec4(iNormal, 0.0)));
	
	ioTexUV = iTexUV;
	
	ioDepth = -Pos.z / V2_CAM_CLIP.y;
	//ioDepth = length(Pos.xyz) / (V2_CAM_CLIP.y - V2_CAM_CLIP.x);
}